|
|
|
|
|
|
|
hMaskBmp = CreateBitmap(bmpSource.bmWidth, bmpSource.bmHeight, _
1, 1, ByVal 0&)
hInvBmp = CreateBitmap(bmpSource.bmWidth, bmpSource.bmHeight, _
1, 1, ByVal 0&)
'*****************************************************************
' Create color bitmaps for the final result and the backup copy
' of the source bitmap
'*****************************************************************
hResultBmp = CreateCompatibleBitmap(objDest.hdc, _
bmpSource.bmWidth, bmpSource.bmHeight)
hSaveBmp = CreateCompatibleBitmap(objDest.hdc, _
bmpSource.bmWidth, bmpSource.bmHeight)
'*****************************************************************
' Select bitmap into the device context (DC)
'*****************************************************************
hSrcPrevBmp = SelectObject(lngSrcDC, picSource)
hSavePrevBmp = SelectObject(lngSaveDC, hSaveBmp)
hMaskPrevBmp = SelectObject(lngMaskDC, hMaskBmp)
hInvPrevBmp = SelectObject(lngInvDC, hInvBmp)
hDestPrevBmp = SelectObject(lngNewPicDC, hResultBmp)
'*****************************************************************
' Make a backup of source bitmap to restore later
'*****************************************************************
BitBlt lngSaveDC, 0, 0, bmpSource.bmWidth, bmpSource.bmHeight, _
lngSrcDC, 0, 0, vbSrcCopy
'*****************************************************************
' Create the mask by setting the background color of source to
' transparent color, then BitBlt'ing that bitmap into the mask
' device context
'*****************************************************************
lngOrigColor = SetBkColor(lngSrcDC, lngMaskColor)
BitBlt lngMaskDC, 0, 0, bmpSource.bmWidth, bmpSource.bmHeight, _
lngSrcDC, 0, 0, vbSrcCopy
'*****************************************************************
' Restore the original backcolor in the device context
'*****************************************************************
SetBkColor lngSrcDC, lngOrigColor
'*****************************************************************
' Create an inverse of the mask to AND with the source and combine
' it with the background
'*****************************************************************
BitBlt lngInvDC, 0, 0, bmpSource.bmWidth, bmpSource.bmHeight, _
lngMaskDC, 0, 0, vbNotSrcCopy
'*****************************************************************
' Copy the background bitmap to the new picture device context
' to begin creating the final transparent bitmap
'*****************************************************************
BitBlt lngNewPicDC, 0, 0, bmpSource.bmWidth, bmpSource.bmHeight, _
objDest.hdc, lngX, lngY, vbSrcCopy
'*****************************************************************
' AND the mask bitmap with the result device context to create
' a cookie cutter effect in the background by painting the black
' area for the non-transparent portion of the source bitmap
'***************************************************************** |
|
|
|
|
|